package com.lmz.project.redis.arithmetic.threadLearn.createthread;


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallabelImpl implements Callable<String> {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallabelImpl callabel = new CallabelImpl();
        FutureTask<String> stringFutureTask = new FutureTask<String>(callabel);
        Thread thread = new Thread(stringFutureTask);
        thread.setName("callable线程");
        thread.start();
        String result = stringFutureTask.get();
        System.out.println(result);
    }

    @Override
    public String call() {
        return Thread.currentThread().getName() + ": hello word";
    }
}
